// 发布/订阅
class EventBus {
  subs: any
  constructor() {
    this.subs = {}
  }
  $on(eventType: string, callback: (...args: any[]) => void) {
    this.subs[eventType] ? this.subs[eventType].push(callback) : (this.subs[eventType] = [callback])
  }
  $emit(eventType: string, ...args: any[]) {
    this.subs[eventType].forEach((callback: (...args: any[]) => void) => callback(...args))
  }
}

export default new EventBus()
